#!/bin/bash
#
#

echo "================================================================="
echo "Script: mysql-create-user.bash (begin)"

DIR=(`pwd`)

COMMON_FUNC=$DIR/common-func.bash
export COMMON_FUNC

if [ ! -f $COMMON_FUNC ]
then
    echo "Please make sure that $COMMON_FUNC exists"
    exit 1
fi

COMMON_MYSQL=$DIR/common-mysql.bash
export COMMON_MYSQL

if [ ! -f $COMMON_MYSQL ]
then
    echo "Please make sure that $COMMON_MYSQL exists"
    exit 1
fi

source $COMMON_FUNC
source $COMMON_MYSQL

echo "Please enter the database user, followed by [ENTER]:"
read DB_USER
echo "Please enter the database user password, followed by [ENTER]:"
read -s DB_PASSWORD

echo ""
SQL="create user '$DB_USER'@'%' identified by '$DB_PASSWORD'"
mysql_root_execute "$SQL"

echo "Script: end"
echo "================================================================="